package com._21cn.cms.article.dao.mybatis;

import com._21cn.cms.article.dao.ArticleDao;
import com._21cn.cms.article.entity.Article;
import com._21cn.cms.article.entity.vo.SearchArticle;
import com._21cn.framework.base.db.mybatis.BaseDaoMybatis;
import com._21cn.framework.flip.PageHashMap;
import com._21cn.framework.flip.PageList;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.stereotype.Repository;

import java.util.Map;

@Repository("articleDao")
public class ArticleDaoMybatis extends BaseDaoMybatis<Article> implements ArticleDao {

    public ArticleDaoMybatis() {
        super();
        setNameSpace( "t_cms_article" );
    }

    @Required
    @Autowired
    @Qualifier("sqlSessionFactory")
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        super.setSqlSessionFactory( sqlSessionFactory );
    }


    public PageHashMap selectMapByMap( Map<String, Object> params, int pageNo, int pageSize, boolean doCount ){
        return query4PageHashMap( getNameSpace() + ".selectByMap", params, pageNo, pageSize, doCount, "id" );
    }

    /**
     *
     * @param params
     * @param pageNo
     * @param pageSize
     * @param doCount
     * @return
     */
    public PageList selectByMapJoinColumn(Map<String, Object> params, int pageNo, int pageSize, boolean doCount) {
        return (PageList< SearchArticle>)query4PageList( getNameSpace() + ".selectByMapJoinColumn", params, pageNo, pageSize, doCount );
    }

}